<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    function Cat(name, color) {
        this.name = name;
        this.color = color;
    }


    var arr = [1, 2, 3, 4];
    var obj = { a: 1, b: 2 };
    var tom = new Cat("Tom", "black");
    var p = new Promise(function () { });
    var date = new Date();
    console.log(arr);
    console.log(p);
    console.dir(date);
    console.log(obj);
    console.log(tom);

    // 判断一个数据是否是数组?
    // console.log(arr instanceof Array);
    // console.log(arr.constructor === Array);
    // console.log(Array.isArray(arr));

    // 判断一个数据是否是纯对象数据? {}

    // 不行 => 都是'object'  (数据类型)
    // console.log(typeof arr);
    // console.log(typeof p);
    // console.log(typeof obj);
    // console.log(typeof tom);

    // 不行 -> 原型链上包含 Object.prototype  (原型链)
    // console.log(arr instanceof Object);
    // console.log(p instanceof Object);
    // console.log(obj instanceof Object);
    // console.log(tom instanceof Object);

    // 找构造函数
    // console.log(arr.constructor === Object);
    // console.log(p.constructor === Object);
    // console.log(obj.constructor === Object);  //true
    // console.log(tom.constructor === Object);  //false

    // 判断是否是纯对象数据
    console.log(Object.prototype.toString.call(arr)); //  '[object Array]'
    console.log(Object.prototype.toString.call(p));   //  '[object Promise]'
    console.log(Object.prototype.toString.call(obj)); //   '[object Object]'
    console.log(Object.prototype.toString.call(tom)); //   '[object Object]'






</script>

</html>